package pl.edu.pw.ee.buildcity.ui.web.jsf.converters;

import pl.edu.pw.ee.buildcity.domain.BuildStatus;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 * @author Mateusz
 * @since 2010-03-21
 */
public class BuildResultConverter implements Converter {
	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		if (value == null) return null;
		return BuildStatus.valueOf(value);
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		if (value == null) return null;
		return ((BuildStatus) value).name();
	}
}
